﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Serialization;
using Microsoft.Practices.Prism.ViewModel;

namespace Data
{
    public class Game : NotificationObject
    {
        #region PathToGlovePieScript

        public string PathToGlovePieScript
        {
            get { return pathToGlovePieScript; }
            set
            {
                if (pathToGlovePieScript != value)
                {
                    pathToGlovePieScript = value;
                    RaisePropertyChanged(() => PathToGlovePieScript);
                }
            }
        }

        private string pathToGlovePieScript;

        #endregion

        #region GameFolder

        public string GameFolder

        {
            get { return gameFolder; }
            set
            {
                if (gameFolder != value)
                {
                    gameFolder = value;
                    RaisePropertyChanged(() => GameFolder);
                }
            }
        }

        private string gameFolder;

        #endregion

        #region GameExe

        public string GameExe
        {
            get { return gameExe; }
            set
            {
                if (gameExe != value)
                {
                    gameExe = value;
                    RaisePropertyChanged(() => GameExe);
                }
            }
        }

        private string gameExe;

        #endregion

        #region GameId

        public string GameId
        {
            get { return gameId; }
            set
            {
                if (gameId != value)
                {
                    gameId = value;
                    RaisePropertyChanged(() => GameId);
                }
            }
        }

        private string gameId;

        #endregion

        #region Name

        public string Name
        {
            get { return name; }
            set
            {
                if (name != value)
                {
                    name = value;
                    RaisePropertyChanged(() => Name);
                }
            }
        }

        private string name;

        #endregion

        #region Image

        [XmlIgnore]
        public ImageSource Image
        {
            get
            {
                if (image == null && !String.IsNullOrEmpty(ImagePath))
                {
                    image = new BitmapImage(new Uri(ImagePath));
                }
                return image;
            }
            set
            {
                if (image != value)
                {
                    image = value;
                    if (image is BitmapImage)
                    {
                        var img = image as BitmapImage;
                        ImagePath = img.UriSource.AbsoluteUri;
                    }
                    RaisePropertyChanged(() => Image);
                }
            }
        }
        [XmlIgnore]
        private ImageSource image;

        #endregion

        #region ImagePath

        public string ImagePath
        {
            get { return imagePath; }
            set
            {
                if (imagePath != value)
                {
                    imagePath = value;
                    RaisePropertyChanged(() => ImagePath);
                }
            }
        }

        private string imagePath;

        #endregion

        #region ToString
        public override string ToString()
        {
            return Name;
        }
        #endregion
    }
}
